/**
 * 状态转换成html代码 state非直接状态需要根据不同的业务模块表示的内容进行换算
 * @param state 状态编码 1 绿色  2 紫色 3 蓝色 4 黄色 5 红色
 * @param msg 提示信息
 * @returns {string} html代码
 */
function stateToHtml(state,msg) {
    var className = "";
    switch (state) {
        case 1:
            className = 'm-badge--success';
            break;
        case 2:
            className = 'm-badge--brand';
            break;
        case 3:
            className = 'm-badge--info';
            break;
        case 4:
            className = 'm-badge--warning';
            break;
        case 5:
            className = 'm-badge--danger';
            break;
        default:
            className = 'm-badge--success';
            break;
    }
    return '<span class="m-badge  '+className+' m-badge--wide"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">' + msg + '</font></font></span>';
}

/**
 *
 * @param state 状态编码 1 绿色  2 紫色 3 蓝色 4 黄色 5 红色
 * @param msg 提示信息
 * @returns {string} html代码
 */
function typeToHtml(state,msg) {
    var className = "";
    var fontClassName = "";
    switch (state) {
        case 1:
            className = 'm-badge--success';
            fontClassName = 'm-font--success';
            break;
        case 2:
            className = 'm-badge--brand';
            fontClassName = 'm-font--brand';
            break;
        case 3:
            className = 'm-badge--info';
            fontClassName = 'm-font--info';
            break;
        case 4:
            className = 'm-badge--warning';
            fontClassName = 'm-font--warning';
            break;
        case 5:
            className = 'm-badge--danger';
            fontClassName = 'm-font--danger';
            break;
        default:
            className = 'm-badge--success';
            fontClassName = 'm-font--success';
            break;
    }
    return '<span class="m-badge '+className+' m-badge--dot"></span><span class="m--font-bold '+fontClassName+'"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">'+msg+'</font></font></span>';
}

/**
 * 消息提示
 * @param msgState 提示状态
 * @param msgTitle 提示标题
 * @param msgContent 提示内容
 */
 function swMsg(msgState,msgTitle,msgContent) {
    if(msgContent!==""&&msgState!==""){
        msgState = msgState === 1 ? "success":"warning";
        swal(msgTitle, msgContent,msgState)
    }else{
        swal(msgTitle)
    }
 }

/**
 * sw情人操作弹窗
 * @param state
 */
function swConfirm(state) {
    var title = state === 1 ? "保存":(state === 2 ? "修改":"删除");
    swal({
        title: "确定"+title+"吗？",
        text: "您的操作将无法还原！",
        type: "warning",
        showCancelButton: !0,
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        reverseButtons: !0
    }).then(function (e) {
        e.value ? swal("操作成功", "", "success") : "cancel" === e.dismiss && swal("取消！", "","error");
    })
 }

/**
 * 跳转URL
 * @param state
 * @param url
 */
function swUrl(state,url) {
    var title = state === 1 ? "成功":"失败";
    swal({
        title: "操作"+title,
        text: "",
        type: "warning",
        confirmButtonText: "确定",
        reverseButtons: !0
    }).then(function (e) {
         window.location.href=url;
    });
 }